<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  // var a = 'var变量a'
  // {
  //     var b = 'var变量b'
  //     console.log(a) // var变量a
  // }
  // console.log(b) // var变量b

  // let c = 'let变量c'
  // {
  //     let d = 'let变量d'
  //     console.log(c)
  // } 

  // try {
  //     console.log(d) // 报错
  // } catch (e) {
  //     console.log(e)
  // }

  function testVar () {
    console.log(name)
    var name = '给var赋的值'
    console.log(name)

    console.log(age)
    let age = '给let赋的值'
    console.log(age)
  }
  testVar()
</script>

</html>